package com.webserver.core;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class WebServerApplication {
    private ServerSocket serverSocket;

    public WebServerApplication(){
        System.out.println("正在启动服务器");

        try {
            serverSocket = new ServerSocket(8088);
        } catch (IOException e) {
            e.printStackTrace();
        }

        System.out.println("服务器启动完成");

    }

    private void start(){

        try {
            System.out.println("等待客户端连接");
            Socket socket = serverSocket.accept();
            System.out.println("客户端连接成功");

            ClientHandler clientHandler = new ClientHandler(socket);
            Thread t = new Thread(clientHandler);
            t.start();


        } catch (IOException e) {
            e.printStackTrace();
        }


    }


    public static void main(String[] args) {
        WebServerApplication wsa = new WebServerApplication();
        wsa.start();
    }
}
